In js, if you want to create an element node, we usually use createElement, but to create a text node, we can use createTextNode () or createComment () for an instance. I will introduce it in detail below.
In Javascript, you can create various types
I. Element Node // test element node, output node name, node type, and node value varliElementsdocument. getElementsByTagName (& quot; li & quot;); for (vari0; I & lt; liElements. length; I ++) {alert (liElements [I]. nodeName);
I. Element nodes
//
Core of DOM: NodeBecause Dom is a tree structure, a node is abstracted as an object node, which is the core object of DOM:There are 12 types of nodes, which are determined by the value of node. nodetype (1-12: JS
Code
Node. element_node (1)
getElementById (ID)This is one of the most common examples of accessing an element through an ID:test Note: If the ID of the element is not unique, then the first element of that ID name will be taken
Getelementsbyname (name)This is done by name
Recently, it was found that the DOMDocument object is very important, and XMLHTTP is also important to note that case sensitivity must not be mistaken.
Attribute:
Attribute list of the Attributes storage node (read-only)
List of child nodes of the
Recently, it was found that the DOMDocument object is very important, and XMLHTTP is also very important. The case must not be wrong. attribute:
1 Attributes storage node attribute list (read-only)
2. List of child nodes of the childNodes storage
Original: Aspose.words: How to add a Node object in another Word documentFirst look at a piece of code that is intended to fetch the first table from Docsource and insert the end of the Doctarget:1 var 0 true ); 2
First look at a piece of code that is intended to fetch the first table from Docsource and insert the end of the Doctarget:1 var 0 true ); 2 docTarget.FirstSection.Body.ChildNodes.Add (table);This code throws an exception: "The NewChild is created
Create node createelement () var node = document.createelement ("div"); Nothing to say, create an element node, but note that the node is not automatically added to the document. 2, create a text node createTextNode () var value =
Create node createelement () var node = document.createelement ("div"); Nothing to say, create an element node, but note that the node is not automatically added to the document. 2, create a text node createTextNode () var value =
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.